Merge "Adding a bunch of hooks from wikiHow into DifferenceEngine, 2nd try"
[lhc/web/wiklou.git] / includes / libs / objectcache / CachedBagOStuff.php
index fc15618..e70a51f 100644 (file)
@@ -21,8 +21,6 @@
  * @ingroup Cache
  */
 
-use Psr\Log\LoggerInterface;
-
 /**
  * Wrapper around a BagOStuff that caches data in memory
  *
@@ -43,18 +41,18 @@ class CachedBagOStuff extends HashBagOStuff {
         * @param BagOStuff $backend Permanent backend to use
         * @param array $params Parameters for HashBagOStuff
         */
-       function __construct( BagOStuff $backend, $params = array() ) {
-               $this->backend = $backend;
+       function __construct( BagOStuff $backend, $params = [] ) {
                parent::__construct( $params );
+
+               $this->backend = $backend;
+               $this->attrMap = $backend->attrMap;
        }
 
        protected function doGet( $key, $flags = 0 ) {
                $ret = parent::doGet( $key, $flags );
-               if ( $ret === false ) {
+               if ( $ret === false && !$this->hasKey( $key ) ) {
                        $ret = $this->backend->doGet( $key, $flags );
-                       if ( $ret !== false ) {
-                               $this->set( $key, $ret, 0, self::WRITE_CACHE_ONLY );
-                       }
+                       $this->set( $key, $ret, 0, self::WRITE_CACHE_ONLY );
                }
                return $ret;
        }
@@ -76,11 +74,6 @@ class CachedBagOStuff extends HashBagOStuff {
                return true;
        }
 
-       public function setLogger( LoggerInterface $logger ) {
-               parent::setLogger( $logger );
-               $this->backend->setLogger( $logger );
-       }
-
        public function setDebug( $bool ) {
                parent::setDebug( $bool );
                $this->backend->setDebug( $bool );